package ch.mueller.android.sensorexample.sensorpages.gpssensor.util;

import java.util.LinkedHashMap;

import ch.mueller.android.sensorexample.sensorpages.gpssensor.util.readerFactoryElements.GPSLineAnalyser;

public class GPSReader {

    private GPSLineReaderFactory gpsLineReaderFactory;

    public GPSReader() {
        gpsLineReaderFactory = new GPSLineReaderFactory();
    }
    
    
    public LinkedHashMap<String, String> convertNMEA2Map(String line) {
        GPSLineAnalyser analyser = null;
        try {
            String messageType = line.substring(3, 6);
            analyser = gpsLineReaderFactory.getGpsLineAnalyser(messageType, line);
        } catch (Exception e) {
            LinkedHashMap<String, String> errorMessage = new LinkedHashMap<String, String>();
            errorMessage.put("ERROR", "No Type Found");
            return errorMessage;
        }
        return analyser.getResult();
        
    }
}
